package com.nj.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nj.api.entity.Product;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


public interface ProductMapper extends BaseMapper<Product> {
    @Select("SELECT u.phone,SUM(bid_money)money FROM b_bid_info i JOIN u_user u ON i.uid = u.id GROUP BY i.uid ORDER BY money DESC LIMIT 3")
    List<Map> getTop3();
    @Update("update b_product_info set left_product_money=left_product_money-#{bidMoney} where id=#{pid} " +
            "and left_product_money>#{bidMoney}")
    int deduct(@Param("pid") Integer pid,@Param("bidMoney") BigDecimal bidMoney);
}
